<? 



$href = $_SERVER["SCRIPT_NAME"];
$host = $_SERVER["REMOTE_ADDR"];
$qs   = $_SERVER["QUERY_STRING"];
if (strlen($_GET ["i"]) > 0) LoadBin64Images($_GET ["i"]);
if (strlen($_GET ["z"]) > 0) LoadBin64Images($_GET ["z"],"u");
$pathdata= file_to_array("path.config");
$path    = trim($pathdata[0]);
$dirname = trim($pathdata[1]);
$parent  = "";
$folders = Array();
$files   = Array();
$d       = $_GET["d"];
$f       = $_GET["f"];
$s       = $_GET["s"];
$r       = $_GET["r"];
$h       = $_GET["h"];
$m       = $_GET["m"];
$efile   = $_GET["efile"];
$remove  = $_GET["remove"];
$select  = $_GET["select"];
$newzoom = $_GET["zoom"];
$session = $_GET["u"];
$edit    = $_GET["e"];
 

if (strlen($d)>0) $dirname = $d;


if (count($_FILES)>0) {
	foreach( $_FILES as $file_name => $file_array ) {
		/*
		print "path: ".$file_array['tmp_name']."<br>\n";
		print "name: ".$file_array['name']."<br>\n";
		print "type: ".$file_array['type']."<br>\n";
		print "size: ".$file_array['size']."<br>\n";
	*/
		$upload_path = $file_array['tmp_name'];
		$upload_name = $file_array['name'];
		$upload_type = $file_array['type'];
		$upload_size = $file_array['size'];
		
		$filetype = exif_imagetype($upload_path); 
		if (strlen($filetype)==0) {
		    print "<font color=red>".$upload_name." does not appear to be an image. Please upload a GIF, JPG or PNG image.</font>";
		} else if ($filetype<4) {
			if ( is_uploaded_file( $upload_path )  ) {
				$tmp = $dirname."/".$upload_name;
				copy($upload_path, $tmp) or die("unable to create info");	 
				print "<script language=jscript>location.href='".$href."?e=e&r=on&efile=".(str_replace($path,"",$tmp))."'</script>"; 
			}  
		} else {
		    print "<font color=red>".$upload_name." cannot be uploaded. Please upload a GIF, JPG or PNG image.</font>";
		}
		exit;
		exit;
		 
	} 
}



$dh = opendir( $dirname ) or die ("couldn't open directory"); 
$real    = realpath($dirname); 
$relpath = str_replace("\\","/",$real); 
$relpath = str_replace($path,"",$relpath);
 
while (! ( ( $file = readdir ( $dh ) ) == false ) ) { 	 
    if (! ($file == ".") ) {
		$subfolder = $relpath."/".$file; 
		$abspath   = $real."/".$file;
		$abspath   = str_replace("\\","/",$abspath); 
		if ( $file == ".." ) { 
		    if ( realpath($abspath) == realpath ($path)) {
			
			} else {
			    $folders [count($folders)] = $abspath;
				$parent = $abspath;
			} 
		} else if (is_dir ($abspath)) {
		    $folders [count($folders)] = $abspath;
      //  } else if (strpos(strtolower($file),".jpg")>0) { 
		} else if (isreadable ($abspath)) {
		    $files [count($files)] = $subfolder;  
		}
    } 
}
closedir( $dh );  

if (!function_exists ("mime_content_type")) {
	function mime_content_type ($file) {
	    $ret = exec ("file -bi " . escapeshellcmd($file)); 
		$i = strpos($ret, ";");
		if ($i > 0) {
		    $ret = substr($ret, 0, $i);
		} 
		return $ret;
	}
}



$filename = $files[0];
$scroll = 0;
if (strlen($f)>0) $filename = $files[$f];
else if (strlen($efile)>0) {
    $filename = $efile;
}
else $f = 0;
if (strlen($s)>0) $scroll = $s;

 

$fullpath  = $path.$filename;


 

$fs = filesize($fullpath);  
$ft = mime_content_type($fullpath); 
$fd = date("F d Y H:i:s.", filemtime ($fullpath));
if ($r=="") $r = "off";
$off = $r=="on"?"off":"on";
$message = $r=="on"?"Show images full size":"Size images to window";
$panelon = $edit=="e"?"display:none":"";


 


$editcookie = $_COOKIE["editcookie"]; 
$editconfig = "_PIMP_edit_data_".$editcookie.".log";
if ($edit=="e") {  // file management
	if (strlen($editcookie)>0) { 
		$arrconfig  = file_to_array($editconfig); 
		$fcontents  = "";
		$unique = true;
		
		
		// rebuld file
		for ($e=1;$e<count($arrconfig);$e++) {
		     parse_str($arrconfig[$e]);
			 if ($file==$fullpath)  {
			     $unique=false;
				 if (strlen($newzoom)>0) {
				     $arrconfig[$e]="file=".$file."&name=".$name."&size=".$size."&zoom=".$newzoom;
				 }  
			 }
			 if ( stripslashes(trim($remove))==stripslashes(trim($file)) ) {
			 // if a removal is indicated, don't write this line
			 } else $fcontents.=$arrconfig[$e]."\n"; 
		}  
		
		 // desginate selected file
		if (strlen($select)>0) {
		    $fcontents = "selected=".$select."\n".$fcontents;
		} else if ($remove=="") {
		    $fcontents = "selected=".$fullpath."\n".$fcontents;
		} else {
		    parse_str($arrconfig[0]);
		    $fcontents = "selected=".$selected."\n".$fcontents;
		} 
		
		// add new file to list
		if (($remove=="")&&$unique) {
			$oi = @imagecreatefromjpeg($fullpath); 
			list($lw,$lh) = getimagesize($fullpath);   
			$fcontents.="file=".$fullpath."&name=".$filename."&size=".$lw.",".$lh."&zoom=1\n";
		} 
		
		// rewrite file
	    WriteToFile($editconfig, $fcontents);
		
		// write result message
		if (strlen($remove)>0) {
		    print $remove. " closed!";
			exit;
		}
		if (strlen($select)>0) {
		    print $select. " selected!";
			exit;
		}
		$arrconfig  = explode("\n", $fcontents);
	} else {
	    savecookie("editcookie", $host, $qs);
	} 
}


?>
<html>
<style>
body, td {font:7pt verdana}
a        {text-decoration:none;color:black}
a:hover  {text-decoration:underline}
input    {font:8pt verdana;border-width:1px}
.outset  { border-right:solid 1px gray;border-bottom:solid 1px gray;
		border-top:solid 1px gainsboro;border-left:solid 1px gainsboro;padding:2px
	  }
</style>   

<script language="javascript" src="xmlextras.js"></script> 
<script language="javascript"> 


// function fb_edit -----------------------------------------------------'
function fb_edit() {
// ----------------------------------------------------------------------'   
    var n,q,s,b,h,a,f=fb_edit.arguments;
    h = location.href.split("?"); 
    if (h[1]) {      
        a = h[1];
        for (var k=0;k<f.length;k+=2) {
			s = "";
			b = false;
            q = a.split("&");
			for (var i=0;i<q.length;i++) {
			    n = q[i].split("=");
			    if (n[0]==f[k]) {
			        s += (s==""?"":"&")+f[k]+"="+f[k+1];
			        b = true;
			    } else s += (s==""?"":"&")+q[i];
			}
			
			if (!b) s += (s==""?"":"&")+f[k]+"="+f[k+1];
			a = s; 
        }                
    } else { 
        s = "";
        for (var k=0;k<f.length;k+=2)
            s += (s==""?"":"&")+f[k]+"="+f[k+1];  
    } 
    try {
         s += "&top="+(pageform.html.scrollTop)
    } catch (ex) {    }
    location.href = h[0]+"?"+s;
} // fb_edit
// **********************************************************************'
</script>
 
<? if (strlen($h)>0) {
  include ("includes/displays/dsp_slide_show.php");
} else { ?> 
<body <? if ($edit!="") { ?>bgcolor="buttonface"<? } ?>  onload="scroll_reset()"  scroll=no topmargin=1 leftmargin=1>

   <!-- workspace -->
   <table bgcolor=white cellspacing="0" cellpadding="1" width="100%">
      <tr>
	   
	     <td colspan="2" class="outset" nowrap >
            <div id=dfilelist <? if ($edit=="e") { ?> style="width:expression(document.body.offsetWidth);height:50;overflow:auto"<? } ?>></div>
		 </td>
	  </tr>
      <tr>
	  
	 
         <td   <? if ($edit!="") { ?>width=200  <? } ?> nowrap <? if ($edit=="e") { ?>bgcolor="#99CCFF"<? } ?> align=center valign=top>
		 
		 <!-- controls -->
       
   <? if ($edit=="e") include ("includes/displays/dsp_edit_controls.php");
      else if ($edit=="b") include ("includes/displays/dsp_file_controls.php");  ?>
         
         </td>
		 
		
         <td valign=top>
         
		 
		 <!-- preview pane -->
   <div class="resizeXY"
    <? if ($edit!="") { ?>
    style="width:expression(document.body.offsetWidth-220);height:expression(document.body.offsetHeight-<?= $edit=="e"?"70":"170" ?>);
     background-color:#FFFFFF;overflow:auto"
	  <? } ?> align="center" id=dworkspace
	 <? if ($edit=="e") { ?>
	 onscroll = "edit_scroll()"
	 <? } ?>
	 >
		   <table width=100% height=100%>
		   <tr>
		      <td>  <? 
				  if ($edit=="e") {
					 $arrconfig  = file_to_array($editconfig);
					 parse_str($arrconfig[0]);
					 for ($k=1;$k<count($arrconfig);$k++) {
						 parse_str($arrconfig[$k]); 
						$active = $file==$selected?"true":"false";?> 
						<script language="javascript">
						i = new editedfile ("<?= $name ?>","<?= $file ?>","<?= $zoom ?>",<?= $active ?>); 
						instance[instance.length]=i
						instance["<?= $name ?>"]=i
						</script><?  
					 }
				  } ?> 
			  </td>
		   </tr>
		   <tr>
		   <td align=center><? 
			    if ($edit=="") { ?>
				<br><div style='width:480;border:solid 1px black'>
				<table align=center cellpadding="0" background="images/Bkgrd.jpg2" bgcolor="#f0f0FF" cellspacing="0" style="border:outset 1px">
				    <tr>
					    <td colspan=4 bgcolor="#FFFFFF">
						<table width=100%>
						   <tr>
						      <td>
							     <font color="#000006"  size=3 face="Verdana, Arial, Helvetica, sans-serif">
								 &nbsp;<b>P</b>HP <strong>I</strong>mage <strong>M</strong>anagement <strong>P</strong>rogram 
								 </font>
							  </td>
							  <td align="right">
							     <img src="images/logo.jpeg"><br>
								 The<b>PIMP</b>
							  </td>
						   </tr>
						</table>
						
						</td>
					</tr>
					<tr> 
					<td bgcolor="#999999"><img src="<?=$href?>?i=px" width="240" height=1></td>
					<td bgcolor="#999999"><img src="<?=$href?>?i=px" width="1" height=1></td>
					<td bgcolor="#999999"><img src="<?=$href?>?i=px" width="1" height=1></td>
					<td bgcolor="#999999"><img src="<?=$href?>?i=px" width="240" height=1></td>
					</tr> 
					<tr>  
					<td colspan=4 bgcolor="#FFFFFF"><img src="<?=$href?>?i=px" width="1" height=1></td>
					</tr> 
					<tr> 
					<td valign="top" style="padding:4px">
					<font size=2 face="Verdana, Arial, Helvetica, sans-serif"><b>Open a Recent File</b></font><br> <br> 
					<table>
					<?
					
					 $arrconfig  = file_to_array($editconfig);
					 if (count($arrconfig)>0) {
						 parse_str($arrconfig[0]);
						 for ($k=1;$k<count($arrconfig);$k++) {
							 parse_str($arrconfig[$k]); 
							$active = $file==$selected?"true":"false";?> 
							<tr>
							   <td align="center">
								  <a href="index.php"><img border="1" height="24" src="thumbnail.php?i=<?=$file?>&h=24"></a>
							   </td>
							   <td valign="top">
								   <a href="<?=$href?>?r=on&e=e&efile=<?=$name?>" style="color:#0000FF "><u><?=strlen($name)>30?"...".substr($name,strlen($name)-30):$name?></u></a><br>
								   <?=str_replace(","," x ",$size)?>
							   </td>
							</tr><?  
							if ($k>5) {
							   ?>
							   <tr>
								  <td colspan="2" align="right">
									  <a href="fmgr.php?f=<?=$editconfig?>">more...</a>
								  </td>
							   </tr>
							   <?
							   break;
							}
						 }
					 } else { ?> 
					   <tr>
						  <td colspan="2">
							  No recent files
						  </td>
					   </tr> <?  
					 } ?>
					
					
					</table>
					</td>
					<td bgcolor="#999999"><img src="<?=$href?>?i=px" width="1" height=320></td>
					<td bgcolor="#FFFFFF"><img src="<?=$href?>?i=px" width="1" height=320></td>
					<td valign="top" style="padding:4px">
					<font size=2 face="Verdana, Arial, Helvetica, sans-serif"><b>Create a New File</b></font>
					<form method="post" action="thumbnail.php">
					<table width="100%" style="border:solid 1px gray" bgcolor="#FFFFFF">
					    <tr>
						   <td>Name:</td>
						   <td><input type=text size=20 value="NewDocument" name=ndn></td>
						</tr>
					    <tr>
						   <td>Width:</td>
						   <td><input type=text size=3 value="400" name=ndw>
						   &nbsp;Height:
						   <input type=text size=3 value="300" name=ndh>
						   </td>
						</tr>
					    <tr>
						   <td valign="top" colspan="2">Background: <br>
						   <input type=radio value='FFFFFF' id=cwhite name=ndc>White<br>
						   <input type=radio value='X' checked id=ctrans name=ndc>Transparent<br>
						   <input type=radio value='FF33FF' id=ccustom name=ndc>Custom<br>
						   <div style="background-color:#FF33FF;width:16;height:16;margin-left:10px" id="colortool" onclick='showColorGrid ()'><img src="images/tool_color.gif"></div>
						   </td>
						</tr>
						   <tr>
						      <td colspan="2" align="right">
							     <input type=submit value="Create Image"><br>
								 <input type=hidden size=3 value="<?= $dirname ?>" name=ndd>
								 <input type=hidden size=3 value="<?= $path ?>" name=ndp>
							  </td>
						   </tr>
					</table>
					</form>
					
					<br>  
					<font size=2 face="Verdana, Arial, Helvetica, sans-serif"><b>Upload a File to Edit</b></font>
					<form method="post" action="<?=$href?>" enctype="multipart/form-data">
					
					
					<input size="15" type="file" name="uploadfile"> 
					 <input type="hidden" name="MAX_FILE_SIZE" value="151200">
					<input type=submit value="Upload">
					 
					</form>
					</td>
					</tr> 
					<tr>  
					<td colspan=4 bgcolor="#CCCCCC"><img src="<?=$href?>?i=px" width="1" height=1></td>
					</tr> 
				     <tr>
					   <td colspan="4" bgcolor="white" style="padding:4px">
					   <a href="<?= $href ?>?e=b">Click <u style="color:blue">here</u> to Browse the server for files</a>.
					   </td>
					 </tr>
					<tr>  
					<td colspan=4 bgcolor="#CCCCCC"><img src="<?=$href?>?i=px" width="1" height=1></td>
					</tr> 
					<tr>  
					<td colspan=4 bgcolor="#FFFFFF"><img src="<?=$href?>?i=px" width="1" height=1></td>
					</tr> 
					<tr>  
					<td colspan=4 bgcolor="#F0F0F0" style="padding:4px" align="right">
					&nbsp;&copy;2005 cyber8 netWorks
					</td>
					</tr> 
				</table>
				</div> 
				<div style="position:absolute;top:0;left:0;display:none" id="colorgrid">
				<table cellpadding="0" cellspacing="1" bgcolor="#663399">
					<tr>
						<td><img src='index.php?i=px' width=1 height=1></td><? 
						$kr=0;
						$u = array("00","33","66","99","CC","FF");
						for ($cr=0;$cr<18;$cr++) print "<td><img src='index.php?i=px' width=12 height=1></td>";
						print "</tr><tr><td><img src='index.php?i=px' width=1 height=12></td>";
						for ($cr=0;$cr<count($u);$cr++) {
							for ($cg=0;$cg<count($u);$cg++) {
								for ($cb=0;$cb<count($u);$cb++) {
								   ?> <td bgcolor="#<?=$u[$cb].$u[$cr].$u[$cg]?>" onclick="setcolorGrid ('<?=$u[$cb].$u[$cr].$u[$cg]?>')"></td ><?
								   $kr++;
								   if ($kr%18==0) {
									  print "</tr><tr>";
									  if ($kr<200) print "<td><img src='index.php?i=px' width=1 height=12></td>";
									}
								}
							}
						} ?> 
					</tr>
				</table>
				</div>
				
				<script language="javascript">
				function showColorGrid () {
				    var d=MM_findObj,T=d("colortool"),W=d("colorgrid");
					with (W) {
					   if (style.display=="inline") {
					       style.display = "none";
					   } else {
						   style.display = "inline";
						   style.left = docx(T);
						   style.top  = docy(T)-W.offsetHeight;
					   }
					}
				}
				
				function setcolorGrid (i) {
				    var d=MM_findObj,T=d("colortool"),W=d("colorgrid"),C=d("ccustom");
					alert (i)
					C.value=i
					T.style.backgroundColor=i
					W.style.display = "none";
				}
				
				function docx(e) {    
					var x = 0;
					try {
						for (var i=e;i.tagName!="BODY";i=i.offsetParent) x += i.offsetLeft;
					} catch (ex) { }
					return x;
				} 
				
				function docy(e) {    
					var y = 0;
					try {
					for (var i=e;i.tagName!="BODY";i=i.offsetParent) y += i.offsetTop;
					} catch (ex) { }
					return y;
				}   
				
				</script>
				
				<?
				} else if (strlen($filename)>0) { ?>
			   <img src="gen.jpg" id=mainpic>
			   <? } ?>
		   </td> 
		   </tr>
		   </table> 
		     
			 
   </div>
   
   
   
     <!-- control panel -->
   <div align=center style="width:expression(document.body.offsetWidth-220);background-color:white;<?= $panelon ?>">
   <? if ($edit=="e") { ?>
	   <? if (strlen($filename)>0) { ?>
	   <img src="<?= $href ?>?i=pc" onclick="goimage(<?= $f-1 ?>)">
	   <img src="<?= $href ?>?i=pd" onclick="goimage(<?= $f+1 ?>)">
	   <? } else {?>
	   No files in this folder
	   <? } ?> 
   <? } ?> 
   </div>
   
   <!-- folder/files list -->
   <div id=Dx onscroll="scroll_display()" style="width:expression(document.body.offsetWidth-220);height:140;
                                           background-color:white;overflow:auto;<?= $panelon ?>">
   <? if ($edit=="b") { ?>
 <?
 
 
 
print "<table id=Tx ><tr>";

/* begin folder list 
 ------------------------------------------------------------------------------ */
 for ($e=0;$e<count($folders);$e++) {
    $abspath = $folders[$e];	
	$arr = explode("/",$abspath);
	$file = $arr[count($arr)-1];
	 print "<td style='font:8pt tahoma;background-repeat:no-repeat;background-position :center center' align=center background='".$href."?i=ps'"; 
	 print ">";
	 print "<div class=deadload title='".$abspath."' style='width:60;height:60;overflow:hidden;margin:20' id='d".$e."' onclick='gofolder(\"".$abspath."\")'
			   ><table cellpadding=0 cellspacing=1><tr>  ";			
		   $tmp = opendir( $abspath ) or die ("couldn't open directory");    
			while (! ( ( $tfile = readdir ( $tmp ) ) == false ) ) { 
				if (! ($tfile == ".") ) {
					 if (strpos(strtolower($tfile),".jpg")>0) { 
						 print "<td><img src='thumbnail.php?w=60&i=".$abspath."/".$tfile."'></td>";
						 break; 
					 }
				}
			} 
			closedir( $tmp );  
	  print "</tr></table></div>$file</td>" ;
 }
  
 
/* begin file list 
 ------------------------------------------------------------------------------ */

for ($e=0;$e<count($files);$e++) {
	$arr = explode("/",$files[$e]);
	$file = $arr[count($arr)-1];
	 print "<td style='font:8pt tahoma";
	 if ($files[$e]==$filename) print ";border:solid 2px blue";
	 print "' align=center>";
	 print "<div class=offload style='width:100;height:100;overflow:hidden' id='d".$e."' onclick='goimage(\"".$e."\")'
			   >".$files[$e]."</div>  </td>"; 
	
}


 
print "</td></table>";
?>     
   
   <? } ?>
   </div>
         </td>
      </tr>
   </table>

<div id=wsborder style="position:absolute;top:0;left:0;border:solid 1px blue"></div> 
<div id=editworkspace   style="position:absolute;top:0;left:0;filter:alpha (opacity=2)"></div>
 

<!-- filmstrip scripts -->   
<script language="javascript">

// mozilla resize stuff
function desktop_background_resize () { // desktop_background_resize
	var Dd = document.getElementsByTagName("DIV");   
	for (var i=0;i<Dd.length;i++)  {	 
		if (Dd[i].className&&Dd[i].className=="resizeX") {
			Dd[i].style.width  = ( (document.all?document.body.offsetWidth:window.innerWidth)   - docx(Dd[i]) ) - 10; 
		}
		if (Dd[i].className&&Dd[i].className=="resizeY") {
			Dd[i].style.height = ( (document.all?document.body.offsetHeight:window.innerHeight) - docy(Dd[i])) - 30;  
		}
		if (Dd[i].className&&Dd[i].className=="resizeXY") { 
			Dd[i].style.height = ( (document.all?document.body.offsetHeight:window.innerHeight) - docy(Dd[i])) - 30;  
			Dd[i].style.width  = ( (document.all?document.body.offsetWidth:window.innerWidth)   - docx(Dd[i])) - 10;  
		}   
	} 
} // desktop_background_resize 

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
} 

function goimage (a) {
    fb_edit ('f',a,'s',Dx.scrollLeft) 
}
function gofolder (a) {
	location.href="<?= $href ?>?e=b&r=<?= $r ?>&d="+a;
}
function scroll_display() {
	try {
		var d = document.all
		if (d) { 
			Dxs = Dx.scrollLeft-100;
			Dbw = document.body.offsetWidth;
			Dbt = Dxs + Dbw + 100;
			for (var k=0,e=0;e<d.length;e++) {
				if (d[e].className=="offload") {
					tx = k * 105;
					if ((tx>=Dxs)) {
						 if ((tx<Dbt)) {
							 di = d[e].innerHTML; 
							 if (di.indexOf("cnimg")<0) {
								 di = "thumbnail.php?i=<?= $path ?>"+di;
								 d[e].innerHTML = "<img  cnimg src='"+di+"'>";
							 }
						 } else break;
					}
					k ++;
				}	
				if (d[e].className=="deadload") {
					k ++;
				}
			}
		}
	} catch (ex) { alert (ex.message) }
	
}
function scroll_reset() {
 //   opendebug ()
	MM_findObj("Dx").scrollLeft = "<?= $scroll ?>";
	scroll_display()
	sizepic()
	
	// desktop_background_resize();
}

function openslides () {
    window.open('<?= $href ?>?h=h&d=<?= $dirname ?>', 'slideshow', 'resizable=yes,menubar=no')
}


var imageurl="",offsetflag=0;
function setoffset (i) {
     addtolog("setoffset",setoffset);
   if (i>16) {
      alert ("Max 1600%")
   } else {
	   Hoffset = i;
	   if (tools[SELECTEDTOOL]._pen) setpen (tools[SELECTEDTOOL]._pen);
	   sizepic ()
   }
}

function hidestatus() {
     addtolog("hidestatus",hidestatus);
	    var d=MM_findObj,S=d("statpanel");
    try {  
		with (S) { 
			style.display   = "none";
			innerHTML = "";
		}
	} catch (ex) { }  
}

function showstatus(message) {
     addtolog("showstatus",showstatus);
    try {    
	    var d=MM_findObj,D=d("dfilelist"),S=d("statpanel");
		var st = mboundary (D);
		with (S) {
			style.display   = "inline";
			style.left      = st[0];
			style.width     = st[2]-st[0];
			innerHTML = message;
		}
	} catch (ex) { }
}



<!-- image size control -->
var CACHEDIMAGE=null,reloaded=0,actual="",FILE="<?= $filename ?>",IMAGEPATH="<?= $path ?>"+FILE;
function cachedimage (x,w,h) {
   this._src    =x;
   this.width   =w;
   this.height  =h
   this._onload = sizepicend;
}
function sizepic () { // starts resize process
     addtolog("sizepic",sizepic);
	var d=MM_findObj,MP=d("mainpic");
    try {    
    <? if ($r=="on") { ?> 
	    MP.onload = null;
		reloaded=0; 
        showstatus("Loading "+FILE+" into image processor...");
		window.setTimeout ("sizepicstart ()", 500);
    <? } else { ?>	
	    MP.src = ""+FILE+"";	 
	<? } ?>
	} catch (ex) { alert (ex.message) }
}
function sizepicerror () { 
    showstatus(""+FILE+" failed to load!");
    document.title = ""+IMAGEPATH+" failed to load!";
}
function sizepicstart () { // loads a full-sized image to get the size
     addtolog("sizepicstart",sizepicstart);
	// document.title = "Reading "+FILE+"...";
	if (CACHEDIMAGE==null) {
		try {    
			showstatus("<a href='javascript:sizepic()'>Reading "+FILE+". Click <u>here</u> if the image fails to load.</a>...");
			
			<? if ($edit=="e") { ?> 
			var i = "i="+IMAGEPATH+"&ac=ac";
			actual = wsdl(i); 
			actual = actual.split(",");  
			<? } ?>
			
			var im = new Image();
			im.onload  = sizepicend;
			im.onerror = sizepicerror;
			im.src = ""+FILE+""; 
			
			} catch (ex) { alert ("sizepicstart error: "+ex.message) }
			
	} else {
	  showstatus("<a href='javascript:sizepic()'>Reloading "+FILE+". Click <u>here</u> if the image fails to load.</a>...");
	  CACHEDIMAGE._onload();
	}
}

function avpreview () {
     addtolog("avpreview",avpreview);
	var d=MM_findObj,MP=d("mainpic"),EW=d("dworkspace"),DR=d("dprevpic");
	boundP = mboundary (MP); // image boundary
	boundV = mboundary (EW); // view area boundary
	outerW = (boundP[2]-boundP[0]) > (boundV[2]-boundV[0]);
	outerH = (boundP[3]-boundP[1]) > (boundV[3]-boundV[1]);
	DR.style.left = ((docx(EW) + EW.offsetWidth) - DR.offsetWidth)-(outerH?20:0)
	DR.style.top  = docy(EW) + 4;
}

var Hoffset = 1;
var hCropX=-1,hCropY=-1,hCropW=-1,hCropH=-1;
function sizepicend () { // fires when resizer image finishes loading 
     addtolog("sizepicend",sizepicend);

	var d=MM_findObj,MP=d("mainpic"),DW=d("dworkspace"),EW=d("editworkspace"),WB=d("wsborder");
	var ZI=d("zoomind"),ZV=d("zoomval"),ZR=d("prevpic"),DR=d("dprevpic");
	showstatus("<a href='javascript:sizepic()'>Downloading "+FILE+"</a>...");
	
	
	MP.onload = function() { // fires when main image loads
		document.title = ""+FILE+" loaded";
		showstatus("<a href='javascript:sizepic()' "+FILE+" loaded. Please wait</a>...");
		<? if ($edit=="e") { ?> 
		
		
		
		  if (CACHEDIMAGE==null) { // cached image and panels
			  CACHEDIMAGE = new cachedimage (""+FILE+"",this.width,this.height); 
			  loadZoom ();	
			  d("zoompic").onload= function() {
		           gozoom(); 
		           refreshFiles();
			   } 
		  } else {
		       d("zoompic").onload = function() {
		           gozoom(); 
		           loadtracersex (MAXBRUSHES,BRUSH_RELOCATE); 
			   }
		  } // cached image and panels
		  
		  
		  
		  
			H = actual[1]*Hoffset; 
			R = Hoffset*100;  
			try {  
				if (ZI) ZI.src   = "thumbnail.php?b=scaler&p="+R
				if (ZV) ZV.value = R+"%";  
			} catch (ez) {  }
			
			this.height = H;
			this.width  = actual[0]*Hoffset;
		

	   
	   
		    imageurl = "i="+IMAGEPATH +"&h="+H; 
			
			
		
		  boundP = mboundary (MP); // image boundary
		  boundV = mboundary (DW); // view area boundary
		  outerW = (boundP[2]-boundP[0]) > (boundV[2]-boundV[0]);
		  outerH = (boundP[3]-boundP[1]) > (boundV[3]-boundV[1]);
		  borders = new Array(EW,WB);
		  for (var v=0;v<2;v++) {
			  if (borders[v]) {
				  with (borders[v]) { // move workspace over image 
						style.left   = docx(MP);
						style.top    = docy(MP);
						style.width  = outerW?DW.offsetWidth-(outerH?20:0):MP.offsetWidth;
						style.height = outerH?DW.offsetHeight-(outerW?20:0):MP.offsetHeight;
						if (v==0&&document.all) style.backgroundColor="white"; 
				  }
			  }
		  }
		  if (historymode>1) historymode=-3
		  
		  // thumbnail.php?fo=100&bg=9187CE&ft=jpeg&w=132&i=/homepages/13/d97505132/htdocs/images/max150.jpg
		  ZR.onload = function () {
		      avpreview();
			  d("zoompic").src="thumbnail.php?i="+IMAGEPATH+"&w=140";
		  }
		  ZR.src="thumbnail.php?fo=100&bg=CC3399&ft=png&w=132&i="+IMAGEPATH;
		  
		  gethistory()
		  
		  
		  if(gx>0) {
			  DW.scrollLeft = (gx*2)-(DW.offsetWidth/2);
			  DW.scrollTop  = (gy*2)-(DW.offsetHeight/2);
		  }  
		  
		  // fire selected tool's _after event
          if (tools[SELECTEDTOOL]._after) tools[SELECTEDTOOL]._after(); 
		  
		<? }   ?>
		
		
		
	 } 
	
	 try {
    <? if (($r=="on")||($edit=="e")) { 
	    if ($edit=="e") print "H=actual[1];\n";
		else print "H=document.body.offsetHeight-180;\n"; ?>   
		 
		imageurl = "i="+IMAGEPATH +"&h="+H; 
		
		
		picurl = "thumbnail.php?"+imageurl
		/*
		
		R = Hoffset*100;  
		try {  
			if (ZI) ZI.src   = "thumbnail.php?b=scaler&p="+R
			if (ZV) ZV.value = R+"%";  
		} catch (ez) {  }
		
		if (H>1.1) {
		    hCropX=-1;
			hCropY=-1;
			hCropW=-1;
			hCropH=-1;
			new_w = Hoffset * actual[0];
			new_h = Hoffset * actual[1];
			if ((new_w>DW.offsetWidth)||(new_h>DW.offsetHeight)) {
			    hCropX = 0;
			    hCropY = 0;
			    hCropW = DW.offsetWidth-20;
			    hCropH = DW.offsetHeight-20;
				
				picurl+="&px="+hCropX+"&py="+hCropY+"&pw="+hCropW+"&ph="+hCropH;
				
			}
		}
		*/
		MP.src = picurl; 
		
		
		 
    <? } else { ?> 
	     MP.src = ""+FILE+""; 
	<? } ?>
    } catch (ex) { alert("mainpic error at "+ex.message) }
}
<? if ($edit=="b") { ?>
window.onresize = sizepic;
<? } ?>


if (document.all) {

} else {
   window.onresize = desktop_background_resize
}
</script>
   </body>
   <? } ?>
</html>

<?


function WriteToFile($path, $content) {
  if(file_exists($path))  unlink ($path);
	$fp = fopen($path, 'w');
	fwrite($fp, $content);
	fclose($fp);  
}
function LoadBin64Images($i,$k="") {
    global $href;
	if ($k=="")
    header ("Content-type: image/gif");
    $imgs = Array();
    $imgs["a"] = "R0lGODlhAwA9AJEAAEJZckhifv///wAAACH5BAUUAAIALAAAAAADAD0AAAIchIMGGMqeTlzz
yXYhpttyDWbiN3pmhXZpSLZeAQA7"; 
    $imgs["b"] = "R0lGODlhAgAuAJEAAOXl5f///////wAAACH5BAUUAAIALAAAAAACAC4AAAIQTACGmtfrmIwU
2ofn1bmCAgA7";
    $imgs["c"] = "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAYEBAQFBAYFBQYJBgUGCQsIBgYICwwKCgsKCgwQ
DAwMDAwMEAwODxAPDgwTExQUExMcGxsbHCAgICAgICAgICD/2wBDAQcHBw0MDRgQEBgaFREV
GiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICD/wAAR
CABkAAUDAREAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAwj/xAAXEAEBAQEAAAAAAAAA
AAAAAAAAEhEB/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/
2gAMAwEAAhEDEQA/AKYoA6AtANdAVgKgFQC0BaAa6ArANgMH/9k=";
    $imgs["d"] = "R0lGODlhDQAMAMQXAHJzt8/P/zg4cU1ccP7+/mpq0CxJr0NDhoqJ71hbsIeIx7+//i0vWubr
9Nnh7qCf55OSxn5/vrzByo2N1MXL1q6t9XN/jwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ACH5BAEAABcALAAAAAANAAwAAAVcICQqShQBaKJCAUK8MKEerBu/hnAo7U00hschEijcGkAh
oAhrOBwUg0KwLKoMWOmEuggsKuDHY0ISJBaLgXo9MJm/g+ezYTkxEpUHQyKh8AcoDBcJBwcC
h4gMiiEAOw==";     
    $imgs["e"] = "R0lGODlhCwALAJEAAAAAAP///5mZmQAAACwAAAAACwALAAACG5SPFsus3R5gM7wwqxVNb4o5
XLhUF/ShS8IKBQA7";
    $imgs["g"] = "R0lGODlhEAAQAKL/AP//////mf/MAMzMmcyZAGZmAAAAAP///yH/C0FET0JFOklSMS4wAt7t
ACH5BAEAAAcALAAAAAAQABAAQANIeLrcV0EIGKqt5kUgoiSZo1DSJ4BaNRQs60Dd1KKixnlf
uBh874etQm1BuVh0o8CtRKARKxPLKqjwwZa5Bgx3ciZLpy5yyEgAADs=";
    $imgs["h"] = "R0lGODlhEAAQAKIEAAAAgICAgAAAAP///////wAAAAAAAAAAACH5BAEAAAQALAAAAAAQABAA
AAM/SLrcGzBCp8K4eDqLrw3bBYyDYAoN12EC+IgjWbrV2rUMF8v4a1+92mAHANIIKlsQCYsZ
c7/n4kSlHpGSrCsBADs=";
    $imgs["i"] = "R0lGODlhCwALALMAAAAzZszMzDNmmUdHRxwcHPHx8WaZmczs/2ZmZqenp8zM/////////wAA
AAAAAAAAACH5BAUUAAwALAAAAAALAAsAAAQzkEk2CJkSaaGEDkyiHMUxKuiAAGzbXkjXGYJx
McgiHBx357ue4qfjyYjBY6Yo/FmeT0YEADs=";
    $imgs["j"] = "R0lGODlhEAAQAKL/AP////j8+Pj8AMbHxoCAgEdHRwAAAP///yH5BAEAAAcALAAAAAAQABAA
QANJKHekbKasOQ24OEvCgRAZFElVZgJko4KXMZDM0pwYfFj0ZYs8vykEAINVsB0EM07H8qIA
gk+IyRbsSVEUixW3A2x12RyYQi4fEgA7LpuLWhQ6fVStXYd2S8QqvmCzAW1Vk7fqiHxOrycA
ADs=";
    $imgs["k"] = "R0lGODlhEAAQAKL/APj4+NDQyICAgAAAAP///wAAAAAAAAAAACH/C0FET0JFOklSMS4wAt7t
ACH5BAEAAAQALAAAAAAQABAAAAM+SLrc/kzISSsQI+utwx1AKI6hh5EAKA6mOrppG2YzHX/p
nOcsntIqUO8U3AllP6FtCEOVLoGodDp1WkMQSAIAOw==";
    $imgs["l"] = "R0lGODlhEAAQAKIEAAAAgICAgAAAAP///////wAAAAAAAAAAACH5BAEAAAQALAAAAAAQABAA
AAM/SLrcGzBCp8K4eDqLrw3bBYyDYAoN12EC+IgjWbrV2rUMF8v4a1+92mAHANIIKlsQCYsZ
c7/n4kSlHpGSrCsBADs=";
    $imgs["m"] = "R0lGODlhEAAQALP/AP////j8yPj8mPjMmPD08MjMYJicAAAAAP///wAAAAAAAAAAAAAAAAAA
AAAAAAAAACH5BAEAAAgALAAAAAAQABAAQARIEMlJKzJBaD1E78VxBWRpZuFVrGzLihdBagZc
YVv+CSnOecDBIGUp3gzImtHgWiWTEl9O18tMf0ORdLPLjrpBIfFALpvNxnQEADs=";
    $imgs["n"] = "R0lGODlhEAAQALMAAAAAAP/MZplmM2ZmM5mZ/+fn1q2pkP/////MmYCAgJmZM+/WxpmZZv//
/wAAAAAAACH5BAUUAA0ALAAAAAAQABAAAARGsMlJq70448FH0sNSjN4mnKfSccBEAEcsz630
Gkuu6y3h+4DdrgUAvIoGhHKJqDVuhiRT6UROmU4DwxDoer3Vongs1pjNEQA7";
    $imgs["o"] = "R0lGODlhCwALAJEAAAAAAP///5mZmQAAACwAAAAACwALAAACFpSPFsus3R5ccj6AMRXT8R5U
kBglZgEAOw==";
    $imgs["p"] = "R0lGODlhCwALAJEAAAAAAP///5mZmQAAACwAAAAACwALAAACGJSPFsus3d4CUTTqbACcL7lV
lwhlZZYkBQA7	";

    $imgs["pa"] = "R0lGODlhEAAQAKIAAGZmmZmZzMzM/////wAAAP///wAAAAAAACH5BAEAAAUALAAAAAAQABAAAANIWKrUvrA0QWuLpIbNA1mZ0I0eI5LdlwFDu7FuAExyO7y2TNcxPMwZXM8GFPmEt+KRl5xJUB3nEyqTTkeA7AfSyHqBEZDjAkkAADs=";
    $imgs["pb"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i/6TJ7H2tJdPp/z1YILDN/x1gy/dYL/lULGlmXv+TdnRtXSEhIYep3P3+/8rKym1tbf///////yH5BAEAAH8ALAAAAAAQABAAAAfegH+CeoSFPDYYFYKLfzd7fpCRGCcTjH9ce5maexILXZWLWnsBpKUSp1Cgf1oWFk1DbgIJswtQLIIxdRwcKFReRl8KCgtMfX9EO1VKP0spazgjM2U9JsZ0RQwIBE9Ib2xCUzoDL30MK3cUDWYXG0kkcQdwA1Z9MB4a6XkAZBshGQcC5JTok+YMPhV50BDoECSDgzYFHvQ5MseDiwtS/HRoEaKGAzEFQBiL4gRMlhxIWgAxcEXNmJDG/myh8eFDmBAG8GCRIcKHxEVMIECIEMFOgz5IkSJgVIGP06dQKwQCADs=";
    $imgs["pp"] = "R0lGODlhEAAQALMAAAAAAIAAAACAAICAAAAAgIAAgACAgMDAwICAgP8AAAD/AP//AAAA//8A/wD//////yH5BAEAAA0ALAAAAAAQABAAAARNEMlJZ7vo6c2fxF2YIU0WBoGGAKzZodwBmGhwPHX6yC6ewjCeJucrCoG/5G42zBGXvdBGKO3wbtaDVsNjabUrFlN2KYkB5caMnG6XxREAOw==";
    $imgs["pq"] = "R0lGODlhEAAQAKL/APj8+Pj8mPjMmMjMYJicAAAAAAAAAAAAACH/C0FET0JFOklSMS4wAt7tACH5BAAAAAAALAAAAAAQABAAAANECLrcTBC618gENmiNo8TAJjJDAYqoVnpsNARriAqBUA6xSNdwgZsZXU1AKBRPPJpguTKBlENm0dlqFZyAq3a7vXi/jQQAOw==";
    $imgs["pr"] = "R0lGODlhCgAKAIAAAP///////yH5BAQUAP8ALAAAAAAKAAoAAAIIhI+py+0PYysAOw==";
    $imgs["ps"] = "R0lGODlhXgBeAOYAAMNmAP/pfv/ai+jmgMqiK//p/+jp9///7+7WRv/318GYA/Lr1f//c7mPAMyZAP//mdi0NNamFuF7CfD89Or/ctvtk////72EAP//zMWMB+LvdP/vhNSUAN6sLPnq+t7ZnMWMAOHEM7l9DOv/hv//jM/AEs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6UAaQR8ZTBC9UxgiEN1262BmWWb5DBCH/lRmDaheoCc8F3rTpZgxfWiCnm0NYMUF8c2IY5opDxhioi8L1aWSWsM25pgVW3KkmDoSANicLK/iQZpk46PMnipAOo6gCSip6BTCblngBFmSWyYF2onrGhaJNEOKCohj+NucV3rDm5plYoKAoCo140UUXJiggwlXIJqusVSIUYYIDXXixow8eeMLPtdhe64kYgwQCADs=";
    $imgs["pt"] = "R0lGODlhEAAQAJH/AP///wAAAP///wAAACH/C0FET0JFOklSMS4wAt7tACH5BAEAAAIALAAA
AAAQABAAAAIYlI+py+2vAjRBwmodzmzzjk2h+GnTiU4FADs=";
    $imgs["pu"] = "R0lGODlhEAAQALP/AP//////AP8AAMDAwICAgICAAIAAAAAA/wAAgAAAAP///wAAAAAAAAAA
AAAAAAAAACH/C0FET0JFOklSMS4wAt7tACH5BAEAAAoALAAAAAAQABAAAARZUMlJq7016c33
TNg3SKBhnqeSjKqCvipbCgZtGzGpCHxv5y1eIRAo8HArC5HYAw4OhwEASj3knk8EQYE4dBG5
KGCAAJfP4agXbEmSz9uOZjQuE0aDvD6viAAAOw==";
    $imgs["pv"] = "R0lGODlhEAAQANUAAAAAAADMAMyZMwDMzMwAAMzMmf//zJkzAP/MM8zMzFJSUq2tlMxmAACE
AJlmAP/Mmf//9wCEhP+ZmWYzAP9SUv97hO/WxplmZpmZZjP/MwD//zMzM8xmM//MZsyZZrW1
tZlmM/8AAHNzc////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAUUACQALAAA
AAAQABAAAAaIQJJwSCwSPRzQBHRZGElIT8FALWBABWKB8xh5IQqAwXPJCqVeb0K0sTw8jo+Q
U/gmqO5Gg8NJQKcGEHgZGQENAgdyW4BUD44ZHR2JQgt8HAZuDxKRCJNDCRwdGo4VIQSIckSg
GgORFAQcE35EXAMREZEeB7NHkb66qUYcDAcTS8FPH8rKT81GQQA7";
	$imgs["px"] = "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="	;
    if ($k!="") {

		while (list($key, $val) = each($imgs)) {
		   echo "<img src='$href?i=$key'>$key";
		}

	}
    
    print base64_decode ($imgs[$i]);
	exit;
}   

function file_to_array($path) { 
   if (file_exists($path)) {
	$fcontents  = implode ('', file ($path)); 
	$fcontents  = trim ($fcontents);
	return explode("\n", $fcontents);
   } else return array();
}

function filetitle($path) { 
    $v = explode ("/", $path);
	return $v[count($v)-1];
}


function savecookie($COOKIENAME,$text,$qs="") { 
     global $href;
     setcookie ($COOKIENAME, $text, time()+60*60*24*30 ); 
     print "<script>location.href='".$href."?".$qs."';</script>";   
     exit;
}

function isreadable ($path) {
    $filetype = exif_imagetype($path);
	$isok = false;
	 
    if (strlen($filetype)==0) {
	    // not an image
	} else if (strpos($path,"workcopy")>0) {
	    // work copy image 
	} else if ($filetype<4) {
	    $isok = true;
	}
	return $isok;
}
?>


